pw = [int(i) for i in input()]

for i in range(4):
    pw[i] = (pw[i] + 3) % 9

pw[0], pw[2] = pw[2], pw[0]
pw[1], pw[3] = pw[3], pw[1]
print("".join([str(i)for i  in pw]))